package org.example.reactive.demo4;

import reactor.core.publisher.Mono;

public class Demo {
    public static void main(String[] args) {
        Mono<Integer> mono = Mono.just(42)
                .doFinally(signalType -> {
                    System.out.println("doFinally:" + signalType);
                })
                .doOnNext(value -> System.out.println("Original value: " + value))
                .doOnSuccess(result -> {
                    System.out.println("Mono completed: " + result);
                })
                .doOnTerminate(() -> {
                    System.out.println("Another side effect after the previous Mono.");
                });

        mono.subscribe(
                result -> {
                    System.out.println("Mono completed: " + result);
                },
                error -> System.err.println("Mono error: " + error.getMessage()),
                () -> {
                    System.out.println("Mono finished");
                }
        );
    }
}
